﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using InstantNaukriDAL;

public partial class BranchLogin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            lblMsg.Text = "";
            clsUserLoginDAL objclsUserLoginDAL = new clsUserLoginDAL();
            IN_TB_USER objIN_TB_USER = new IN_TB_USER();
            objIN_TB_USER = objclsUserLoginDAL.GetUserByUserNamePassword(txtUserName.Text, txtPassword.Text);
            if (objIN_TB_USER != null)
            {

//Added commesnt
                if (objIN_TB_USER.ROLEID == 5)
                {
                    Session["UserId"] = objIN_TB_USER.ID.ToString();
                    string roleid = clsEncryptionDecryption.Encrypt("5");
                    clsBranchMasterDAL objclsBranchMasterDAL = new clsBranchMasterDAL();
                    IN_TB_BRANCH_MST objIN_TB_BRANCH_MST = new IN_TB_BRANCH_MST();
                    objIN_TB_BRANCH_MST = objclsBranchMasterDAL.GetBranchById(objIN_TB_USER.ID);
                    if (objIN_TB_BRANCH_MST != null)
                    {
                        Session["EmployerId"] = objIN_TB_BRANCH_MST.ID.ToString();
                        Response.Redirect("PostJobs.aspx?roleid=" + roleid);
                    }
                    else
                        lblMsg.Text = "Invalid Credentials For Branch !";
                }
                else
                    lblMsg.Text = "Invalid Credentials For Branch !";
            }
            else
                lblMsg.Text = "Invalid UserName or Password !";
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}
